package cn.codeinn.generator.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import cn.codeinn.generator.entity.Table;

public interface GeneratorMapper {

	@ResultType(Table.class)
	@Select("SELECT table_name tableName, engine, table_comment tableComment, create_time createTime FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = (SELECT DATABASE()) ${tableName}")
	List<Table> queryList(@Param("tableName") String tableName);

	@Select("SELECT table_name tableName, engine, table_comment comments, create_time createTime FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = (SELECT DATABASE()) AND TABLE_NAME = #{tableName}")
	Map<String, String> queryTable(@Param("tableName") String tableName);

	@Select("SELECT column_name columnName, data_type dataType, column_comment comments, column_key columnKey, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = #{tableName} AND TABLE_SCHEMA = (SELECT DATABASE()) ORDER BY ORDINAL_POSITION")
	List<Map<String, String>> queryColumns(@Param("tableName") String tableName);
}
